// pages/my_message/my_message.js

import config from './../../config';
import {
    empty,
    message,
    session,
    getOpenId,
} from './../../utils/helper';
import {
    getMyMessage
} from './../../services/my_message';
import qs from 'qs';

//获取应用实例
const app = getApp();
//实例化本地缓存
const cookie = new session();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        lists: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        //显示当前页面的转发按钮
        wx.showShareMenu({
            withShareTicket: true
        });
        let that = this;
        getOpenId(openid => {
            getMyMessage({
                openid: openid
            }, {
                    success: (res) => {
                        that.setData({
                            lists: res.data
                        });
                    }
                });
        });
    },

    //跳转到在线咨询
    tiao_lawyer: function(e) {
        let params = e.currentTarget.dataset;
        wx.navigateTo({
            url: '/pages/free_zx/free_zx?' + qs.stringify(params),
        });
    },

        /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.onLoad();
        wx.stopPullDownRefresh();
    }
})